package ltd.smallwang.infrastructure.exception;

import com.alibaba.cola.exception.BizException;
import com.alibaba.cola.exception.SysException;
import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * @author justd
 */
@Getter
public enum TaskErrorCode {
  /**
   * 任务不存在
   */
  TASK_NOT_FOUND("0001", "task not found", HttpStatus.BAD_REQUEST);

  private static final String BASE_CODE = "0003";

  private final String errorCode;

  private final String errorMessage;

  private final HttpStatus httpStatus;

  TaskErrorCode(String errorCode, String errorMessage, HttpStatus httpStatus) {
    this.errorCode = BASE_CODE + errorCode;
    this.errorMessage = errorMessage;
    this.httpStatus = httpStatus;
  }

  public BizException buildBizException() {
    return new BizException(errorCode, errorMessage);
  }

  public SysException buildSysException() {
    return new SysException(errorCode, errorMessage);
  }
}
